//
//  LYQMineResourcesManageViewController.m
//  ZCProject
//
//  Created by Zheng on 2016/12/13.
//  Copyright © 2016年 Zheng. All rights reserved.
//

#import "LYQMineResourcesManageViewController.h"
#import "LYQMineConsultingViewController.h"

#import "LYQMineResourcesManageCell.h"
#import "LYQResourcesManageStatusCell.h"

#define kLYQMineResourcesManageCell_ID @"kLYQMineResourcesManageCell_ID"
#define kLYQResourcesManageStatusCell_ID @"kLYQResourcesManageStatusCell_ID"

@interface LYQMineResourcesManageViewController () <UITableViewDelegate,UITableViewDataSource>

@end

@implementation LYQMineResourcesManageViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.navigationItem.title = @"资源管理";
    
    self.listTableView.delegate = self;
    self.listTableView.dataSource = self;
    [self.listTableView registerClass:[LYQMineResourcesManageCell class] forCellReuseIdentifier:kLYQMineResourcesManageCell_ID];
    [self.listTableView registerClass:[LYQResourcesManageStatusCell class] forCellReuseIdentifier:kLYQResourcesManageStatusCell_ID];
    self.listTableView.sectionHeaderHeight = kWScale(10);
    self.listTableView.estimatedSectionHeaderHeight = kWScale(10);

    
}

#pragma mark - tableview datasource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 3;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 2;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if (indexPath.row == 0) {
        LYQMineResourcesManageCell *cell = [tableView dequeueReusableCellWithIdentifier:kLYQMineResourcesManageCell_ID forIndexPath:indexPath];
        return cell;
    } else {
        LYQResourcesManageStatusCell *cell = [tableView dequeueReusableCellWithIdentifier:kLYQResourcesManageStatusCell_ID forIndexPath:indexPath];
        
        if (indexPath.section == 0) {
            cell.statusLbl.textColor = RGB(252, 107, 74, 1);
            cell.statusLbl.layer.borderColor = [RGB(252, 107, 74, 1) CGColor];
        } else {
            cell.statusLbl.textColor = kLYQGray;
            cell.statusLbl.layer.borderColor = [kLYQGray CGColor];
        }
        
        return cell;
    }
}

#pragma mark - tableview delegate
#pragma mark 单元格高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        return kWScale(120);
    } else {
        return kWScale(50);
    }
}

#pragma mark 尾视图高度
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
    return 0.0001f;
}

#pragma mark 分割线偏移量
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {
        [cell setSeparatorInset:UIEdgeInsetsMake(0, kWScale(10), 0, 0)];
    }
    
    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {
        [cell setLayoutMargins:UIEdgeInsetsMake(0, kWScale(10), 0, 0)];
    }
}

#pragma mark 单元格点击事件
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
#pragma mark 跳转到咨询列表
    LYQMineConsultingViewController *mcVC = [[LYQMineConsultingViewController alloc] init];
    [self.navigationController pushViewController:mcVC animated:YES];
    
}

#pragma mark - 内存警告
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
